--1.参数列表
local seckillId = ARGV[1]
local uid = ARGV[2]
--2.key
local stockKey = 'seckill:stock:'..seckillId
local orderKey = 'seckill:order:'..seckillId
--3.脚本业务
if(tonumber(redis.call('get',stockKey)) <= 0)then
    return 1
end
if(redis.call('sismember',orderKey,uid) == 1)then
    return 2
end
redis.call('incrby',stockKey, -1)
redis.call('sadd',orderKey,uid)
return 0